<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>基本资料</title>
    {include file="common/_require"}

    <script>
        var currentHeaderNavItem = 'Admin';
        var currentLeftNavItem = 'index';
    </script>
</head>

<body class="layui-layout-body">

    <div class="layui-layout layui-layout-admin">
        {include file="common/_header"}

        {include file="common/left_admin_manage"}

        <div class="layui-body">

            <div style="padding:15px">
                <div class="main-header">
                    <span class="layui-breadcrumb">
                        <a>首页</a>
                        <a><cite>添加管理员</cite></a>
                    </span>
                </div>
                <div class="main-container">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <fieldset class="layui-elem-field">
                                <legend>添加管理员</legend>
                                <div class="layui-field-box">
                                    <form action="{:url('Admin/save')}" method="POST" class="layui-form">
                                        <div class="layui-form-item">
                                            <div class="layui-form-label">登录账号</div>
                                            <div class="layui-input-block">
                                                <input type="text" name="account" required lay-verify="required"
                                                    value="" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-form-label">昵称</div>
                                            <div class="layui-input-block">
                                                <input type="text" name="nickname" required lay-verify="required"
                                                    value="" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-form-label">密码</div>
                                            <div class="layui-input-block">
                                                <input type="password" name="password"
                                                    value="" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-form-label">管理组</div>
                                            <div class="layui-input-block">
                                                <select name="group_id" lay-verify="">
                                                    <option value="">请选择一个分组</option>
                                                    {volist name='group_list' id='group'}
                                                        <option value="{$group.id}">{$group.name}</option>
                                                    {/volist}
                                                </select>
                                                <div class="layui-form-mid layui-word-aux">
                                                    不设置分组，帐号拥有所有权限
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-form-label">头像</div>
                                            <div class="layui-input-block">
                                                <div>
                                                    <div class="layui-btn upload-admin-avatar">上传</div>
                                                </div>
                                                <div>
                                                    <img class="layui-circle admin-avatar" style="width: 80px" src=""
                                                        alt="" srcset="">
                                                </div>
                                                <input type="hidden" name="avatar" value="" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <button class="layui-btn layui-btn-fluid" type="submit">创建</button>
                                        </div>
                                    </form>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        {include file="common/_footer"}

        <script>
            layui.config({
                base: '/static/lib/layui/lib/cropper/'
            }).use(['layer', 'upload', 'croppers','form'], function () {
                var upload = layui.upload;
                var croppers = layui.croppers;


                var uploadSiteLogo = croppers.render({
                    elem: '.upload-admin-avatar',
                    url: '{:url("File/save")}',
                    data: {
                        type: 2,
                        dir: 'admin_avatar'
                    },
                    saveW: 150 //保存宽度
                        ,
                    saveH: 150,
                    mark: 1 / 1 //选取比例
                        ,
                    area: '900px' //弹窗宽度
                        ,
                    accept: 'images',
                    done: function (result) {
                        if (result.code == 0) {
                            layer.msg('上传成功');
                            $('input[name="avatar"]').val(result.data.save_name);
                            $('.admin-avatar').attr('src', result.data.src);
                        } else {
                            layer.msg(result.msg)
                        }
                    }
                })

            })
        </script>
    </div>
</body>

</html>